package com.tour.bean;

import org.json.JSONObject;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.Serializable;

/**
 * @ClassName BaseParam
 * @Author 张梦兴
 * @Date 2020/3/11 21:02
 * @describe
 */
public class BaseParam  implements Serializable {

    private static final long serialVersionUID = 1L;
    /**
     * 指令
     */
    private Integer cmd;
    /**
     * 指令类型
     */
    private Integer cmdType = -1;
    /**
     * 指令值
     */
    private Integer cmdValue = -1;

    /**
     * 页码
     */
    private Long page;
    /**
     * 每页大小，即包含多少条记录
     */
    private Long pageSize;
    /**
     * 排序列名
     */
    private String sortField;
    /**
     * 排序方向
     */
    private String sortDirection;
    /**
     * 前端传递的参数JSON参数
     */
    private JSONObject paramJson;
    /**
     * 请求
     */
    private HttpServletRequest request;
    /**
     * 响应
     */
    private HttpServletResponse response;


    /**
     * 每页开始行记录号
     * @return
     */
    public int getStartRow() {
        return (page.intValue() - 1) * pageSize.intValue();
    }

    /**
     * 每页结束行记录号
     * @return
     */
    public int getEndRow() {
        return page.intValue() * pageSize.intValue();
    }



    public Integer getCmd() {
        return cmd;
    }

    public void setCmd(Integer cmd) {
        this.cmd = cmd;
    }

    public Integer getCmdType() {
        return cmdType;
    }

    public void setCmdType(Integer cmdType) {
        this.cmdType = cmdType;
    }

    public Integer getCmdValue() {
        return cmdValue;
    }

    public void setCmdValue(Integer cmdValue) {
        this.cmdValue = cmdValue;
    }



    public Long getPage() {
        return page;
    }

    public void setPage(Long page) {
        this.page = page;
    }

    public Long getPageSize() {
        return pageSize;
    }

    public void setPageSize(Long pageSize) {
        this.pageSize = pageSize;
    }

    public String getSortField() {
        return sortField;
    }

    public void setSortField(String sortField) {
        this.sortField = sortField;
    }

    public String getSortDirection() {
        return sortDirection;
    }

    public void setSortDirection(String sortDirection) {
        this.sortDirection = sortDirection;
    }

    public JSONObject getParamJson() {
        return paramJson;
    }

    public void setParamJson(JSONObject paramJson) {
        this.paramJson = paramJson;
    }

    public HttpServletRequest getRequest() {
        return request;
    }

    public void setRequest(HttpServletRequest request) {
        this.request = request;
    }

    public HttpServletResponse getResponse() {
        return response;
    }

    public void setResponse(HttpServletResponse response) {
        this.response = response;
    }

    @Override
    public String toString() {
        return "BaseParam [cmd=" + cmd + ", cmdType=" + cmdType + ", cmdValue=" + cmdValue + ", page=" + page
                + ", pageSize=" + pageSize + ", sortField=" + sortField + ", sortDirection=" + sortDirection
                + ", paramJson=" + paramJson + ", request=" + request + ", response=" + response + "]";
    }



}